package com.itheima.manager_system.service;

import com.itheima.manager_system.dao.StudentDao;
import com.itheima.manager_system.domain.Student;

import java.util.ArrayList;

//业务类
public class StudentService {


    public boolean isExist(String id) {
        StudentDao studentDao = new StudentDao();
        //对id进行判断
        int index = getIndex(id, studentDao.getList());
        if (index != -1) {
            return false;//
        } else {
            return true;
        }
    }

    public int getIndex(String id, ArrayList<Student> list) {
        int index = -1;
        for (int i = 0; i < list.size(); i++) {

            if (list != null && id.equals(list.get(i).getId())) {
                index = i;
                break;
            }
        }
        return index;
    }

    public boolean isEmpty(ArrayList<Student> list) {
        if(list==null||list.isEmpty()){
            return true;
        }else{
            return false;
        }

    }
}
